package com.richinfo.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapUtils extends org.apache.commons.collections.MapUtils{
	/**
	 * @return HashMap
	 */
	public static <K,V> Map<K,V> newMap(){
		return new HashMap<>();
	}
	
	public static <K,V> List<V> getValue(List<Map<K, V>> source, K targetKey){
		List<V> valueList = new ArrayList<>();
		
		for (Map<K,V> map : source) {
			valueList.add(map.get(targetKey));
		}
		
		return valueList;
	}
	
	public static <K,V> List<Map<K, V>> getValues(List<Map<K, V>> source, K... targetKey){
		List<Map<K, V>> valueList = new ArrayList<>();
		
		for (Map<K,V> map : source) {
			Map<K, V> target = new HashMap<>();
			
			for (K key : targetKey) {
				target.put(key, map.get(key));
			}
			
			valueList.add(target);
		}
		
		return valueList;
	}
}
